'''for i in range(900,1000,5):
    print(i)
    def factoria(n):#形参
    sum=1
    for i in range(1,n):
        sum*=i
    return sum
n=9
s=factoria(n)#实参
print(s)'''
def get_inputs():
    prob_A=eval(input("请输入运动员A获胜的几率（0~1）"))
    prob_B=round(1-prob_A,2)
    times=eval(input("请输入一共要比赛的场次"))
    print(prob_A,prob_B,times)
    A,B=game(prob_A,prob_B,times)
    print("A赢的场次",A)
    print("B赢的场次", B)
def game(prob_A,prod_B,times):
    win_A,win_B=0,0
    for i in range(times):
        scord_A,scord_B=oneGame(prob_A,prod_B)
        if scord_A>scord_B:
            win_A+=1
        else:
            win_B+=1
    return win_A,win_B
import random
def oneGame(prob_A,prod_B):
    scord_A,scord_B=0,0
    while True:
        if random.random()<prob_A:
            scord_A+=1
        else:
            scord_B+=1
        if scord_A==21 or scord_B==21:
            return scord_A,scord_B
get_inputs()